<template>
  <div>
    <div class="navbar">
      <van-nav-bar
        title="购物车"
        left-arrow
        @click-left="onClickLeft"
        :border="false"
      />
    </div>
    <div class="body">
      <div v-for="item in information" :key="item.id">
        <Shop
          :price="item.price"
          :name="item.name"
          :imgname="item.imgname"
          :time="item.time"
          :num="item.num"
        ></Shop>
      </div>
    </div>
  </div>
</template>

<script>
import Shop from "@/components/shop.vue";
import { shopCart, shopAdd } from "@/api/request";
import { mapState } from "vuex";
export default {
  data() {
    return {
      checked: true,
      information: "",
    };
  },
  computed: {
    ...mapState(["usee"]),
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    // 获取购物车数据
    shop() {
      console.log();
      shopCart({ uid: this.$store.state.user.uid }).then((res) => {
        console.log(res);
        this.information = res.data.message;
      });
    },
    // +1
    add(name) {
      shopAdd({ uid: this.$store.state.user.uid, name, num }).then((res) => {
        console.log(res);
      });
    },
  },
  components: {
    Shop,
  },
  mounted() {
    this.shop();
  },
};
</script>

<style lang="scss" scoped>
.body {
  width: 90%;
  height: 535px;
  margin: 0 auto;
  overflow: scroll;
}
.van-nav-bar {
  ::v-deep .van-icon {
    color: black;
  }
  ::v-deep .van-nav-bar__title {
    font-weight: bold;
    font-family: "黑体";
  }
}
.van-card {
  background: none;
  border-bottom: 1px solid ghostwhite;
  margin-bottom: 5px;
  .van-card__footer {
    .van-checkbox {
      position: relative;
      bottom: 70px;
      left: 90px;
    }
    display: flex;
    justify-content: flex-end;
    div {
      display: flex;

      .van-button {
        // background-color: #ffd030;
        height: 15px;
        width: 35px;
        color: black;
      }
      p {
        display: inline-block;
        margin: 0 8px;

        text-align: center;

        font-size: 16px;
      }
    }
  }
}
.img {
  width: 35px;
  height: 35px;
  border-radius: 50%;
}
span {
  font-size: 16px;
}
</style>
